<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="/struts-dojo-tags" prefix="sx"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="<s:url value="/style.css"/>" rel="stylesheet" type="text/css"/>
<title>Edit Appointment</title>
<sx:head/>
</head>
	<body>
		<jsp:include page="/navigation/navigation.jsp"/>
		<div id="mainBox">
				<s:if test="actionMode=='createAppointment'">
					<center><h2>Create Appointment</h2></center>
				</s:if>
				<s:if test="actionMode=='updateAppointment'">
					<center><h2>Update Appointment</h2></center>
				</s:if>
			<center>
				<s:form name="editAppointmentForm" action="editAppointment" method="post">
					<table width="400px">
					<s:if test="actionMode=='updateAppointment'">
						<tr>
							<td>ID:</td>
							<td><s:property value="retrievedAppointment.appointmentId"/></td>
						</tr>
					</s:if>
						<tr>
							<td>Patient:</td>
							<td><s:property value="retrievedAppointment.patient.name"/></td>
						</tr>
						<tr>
							<td>Doctor:</td>
							<td><s:property value="retrievedAppointment.doctor.name"/></td>
						</tr>
						<sx:datetimepicker name="selectedDate" label="Date" displayFormat="yyyy-MM-dd"/>
						<s:select name="retrievedAppointment.startTime" value="%{retrievedAppointment.startTime.substring(0, 5)}" label="Start Time" list="timeMap"  required="true"/>
	   					<s:select name="retrievedAppointment.endTime"  value="%{retrievedAppointment.endTime.substring(0, 5)}" label="End Time" list="timeMap"  required="true"/>
	   					<s:textfield name="retrievedAppointment.location" label="Location"/>
	   					<s:hidden name="retrievedAppointment.appointmentId" value="%{retrievedAppointment.appointmentId}" />
	   					<tr>
	   						<s:if test="actionMode=='createAppointment'">
	   							<s:hidden name="selectedPatientId" value="%{retrievedAppointment.patient.id}" />
	   							<s:hidden name="selectedDoctorId" value="%{retrievedAppointment.doctor.id}" />
								<s:submit value="Create" method="createAppointment"/>
							</s:if>
							<s:if test="actionMode=='updateAppointment'">
								<s:submit value="Update" method="updateAppointment"/>
							</s:if>
						</tr>
						
					</table>		
					<div id="actionResult"><s:property value="#session.actionResult"/></div>
				</s:form>
			</center>	
		</div>
	</body>
</html>